class Library:
    def __init__(self):
        self.books = {}

    def addBook(self, book):
        if book.id in self.books:
            print("Book already exists.")
        else:
            self.books[book.id] = book
            print("Book added successfully.")

    def delete_book(self, book_id):
        if book_id in self.books:
            del self.books[book_id]
            print("Book deleted successfully.")
        else:
            print("Book not found.")

    def update_book(self, book_id, title=None, author=None, year=None):
        if book_id in self.books:
            if title:
                self.books[book_id].title = title
            if author:
                self.books[book_id].author = author
            if year:
                self.books[book_id].year = year
            print("Book updated successfully.")
        else:
            print("Book not found.")


    def query_book(self, book_id):
        if book_id in self.books:
            print(self.books[book_id])
        else:
            print("Book not found.")

    def list_books(self):
        for book in self.books.values():
            print(book)
